# for

for x in (1,2,3):
    print(x)
else:
    print("loop over")      #正常循环完成会输出else的内容

d={'name':'John','age':12}
for x in d:                 #迭代的是key
    print(x)

for (a,b) in ((1,2),(2,3),(3,4)):
    print(a+b)

# 100~999的10个回文数字
a=[]
for x in range(100,1000):
    s=str(x)
    if s[0]!=s[2] : continue
    a.append(x)
    if len(a)==10 : break
print(a)

## while
#计算1加到100
i=1
sum=0
while i<=100:
    sum+=i
    i+=1
print(sum)


